package com.gakj.truck.third.api.controller;

import com.alibaba.fastjson.JSONObject;
import com.gakj.truck.third.api.service.TruckInquiryService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 第三方求购信息相关操作
 * Created by gc on 2016/5/13.
 */
@RestController
@RequestMapping(value = "/third/inquiry")
public class TruckInquiryController {

    private static final Logger LOGGER = LoggerFactory.getLogger(UserDtoController.class);
    @Autowired
    TruckInquiryService inquiryService;


    @RequestMapping(value = "/saveOrUpdate",method = RequestMethod.POST)
    public JSONObject update(
//        @RequestParam(value = "truckid",defaultValue = "") Long truckid,
        @RequestParam(value = "data",defaultValue = "") String data,
        @RequestParam(value = "source",defaultValue = "0") String source
    ){

        LOGGER.info("求购更新接口:updateUser");
//        LOGGER.info("求购id:"+truckid);
        LOGGER.info("更新信息:"+data);
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(data)){
            result.put("resMsg","传递数据为空!");
            result.put("resCode","0");
            return result;
        }
        result = inquiryService.saveOrUpdate(data);
        return result;
    }

    @RequestMapping(value = "/deal",method = RequestMethod.GET)
    public JSONObject dealOldData(){
        return inquiryService.dealOldData();
    }
}
